import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  
  // data
  state: {
    user:{
		"userName":"陆小叁",
		"age":"21"
	},
	userList:[
		{name:"杨过",gender:"男",address:"山东",age:"30"},
		{name:"小龙女",gender:"女",address:"河南",age:"35"},
		{name:"郭靖",gender:"男",address:"山西",age:"36"},
		{name:"黄蓉",gender:"女",address:"北京",age:"36"},
		{name:"郭襄",gender:"女",address:"广东",age:"18"},
	]
  },
  
  // computed
  getters:{
	  
	  getUserList(state){
		  return state.userList;
	  },
	  
	  getAge(state){
		  return state.user.age;
	  }
	  
  },
  
  // 同步方法
  mutations: {
	  
	  setUserList(state,userList){
	  		  this.state.userList=userList; 
	  }
  },
	
  // 异步方法
  actions:{
  },
  
})

export default store